<template>
	<!-- title部分 -->
	<view class="title">
		<view class="title_leftbox" @click="goToWode">
			<image class="title_leftbox_image_fanhui" src="../../static/返回.png"></image>
		</view>
		<view class="title_middlebox">
			<view class="title_middlebox_text">追号记录</view>
		</view>
		<view class="title_rightbox">
			<view class="title_rightbox_text"></view>
		</view>
	</view>

	<!-- tab部分 -->
	<view class="tabbox">
		<view class="tabbox_text" v-for="(tab, index) in tabs" :key="index" :class="{ 'active': subCurrent === index }"
			@click="subChecked(index)">
			{{ tab }}
		</view>
	</view>

	<!-- xuanhao部分 -->
	<view v-if="subCurrent === 0" class="content">
		<view class="zhanwubox">
			<image class="zhanwubox_img" src="../../static/zanwu.png"></image>
			<view class="zhanwubox_text">暂无数据1</view>
		</view>
	</view>

	<view v-if="subCurrent === 1" class="content">
		<view class="zhanwubox">
			<image class="zhanwubox_img" src="../../static/zanwu.png"></image>
			<view class="zhanwubox_text">暂无数据2</view>
		</view>
	</view>
	<view v-if="subCurrent === 2" class="content">
		<view class="zhanwubox">
			<image class="zhanwubox_img" src="../../static/zanwu.png"></image>
			<view class="zhanwubox_text">暂无数据3</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				subCurrent: 0, // 默认选中第一个子tab
				tabs: ['全部', '进行中', '已结束/停止'],
			}
		},
		methods: {
			goToWode() {
				// 在tabbar中使用uniapp的switchTab方法跳转
				uni.switchTab({
					url: '/pages/wode/wode', // 我的路径
				});
			},
			subChecked(index) {
				this.subCurrent = index;
			},
		}
	}
</script>

<style>
	/* 以下是title部分样式 */
	.title {
		background-color: rgb(226, 50, 52);
		display: flex;
		align-items: center;
		justify-content: space-between;
		/* 使左右盒子分别位于两侧 */
		padding: 2%;
	}

	.title_leftbox {
		display: flex;
		align-items: center;
		justify-content: center;
		/* 使图标居中 */
	}

	.title_leftbox_image_fanhui {
		width: 17px;
		height: 23px;
	}

	.title_middlebox {
		flex-grow: 1;
		/* 使中间盒子占据剩余空间 */
		display: flex;
		align-items: center;
		justify-content: center;
		/* 使文本居中 */
	}

	.title_middlebox_text {
		font-size: 20px;
		color: white;
		font-weight: 900;
	}

	.title_rightbox {
		display: flex;
		align-items: center;
		justify-content: center;
		/* 使文本居中 */
	}

	.title_rightbox_text {
		color: white;
	}

	/* 以下是 tab 部分样式 */

	.tabbox {
		display: flex;
		align-items: center;
		background: white;
		height: 45px;
		font-size: 16px;
		border-bottom: 2px solid #eee;
	}

	.tabbox_text {
		flex: 1;
		text-align: center;
		cursor: pointer;
	}

	/* tab被选样式 */
	.active {
		position: relative;
		color: #E23234;
		font-weight: bold;
	}

	.active::after {
		content: "";
		position: absolute;
		width: 23px;
		height: 3px;
		background-color: #E23234;
		left: 0;
		right: 0;
		margin: 0px auto;
		top: 28px;
		border-radius: 5px;
	}

	.content {
		display: flex;
		align-items: center;
		justify-content: center;
		height: 70vh;
	}

	.zhanwubox_img {
		width: 60px;
		height: 60px;
		display: block;
	}

	.zhanwubox_text {
		color: rgb(192, 196, 204);
		font-size: 14px;
	}
</style>
